package pool.model;

import java.util.Random;

public class DefaultThread extends Thread implements IThread {

	/** ID number */
	private int id = DEFAULT_ID;
	private boolean inUse;


	/** default constructor */
	public DefaultThread() {
		System.out.println("Thread with default id: " + id + " created!");
	}


	/** 1 argument constructor */
	public DefaultThread(int id) {
		this.id = id;
		System.out.println("Thread with id: " + id + " created!");
	}


	/** set val inUse */
	public void setInUse(boolean inUse) {
		this.inUse = inUse;
	}


	/** has val inUse */
	public boolean isInUse() {
		return inUse;
	}


	@Override
	/** thread start */
	public void run(){
		System.out.println("Start: " + this.id);
		
		try {
			Random random = new Random();
			Thread.sleep(random.nextInt(1000));

		} catch(Exception e) {
			System.err.println("Thread sleep exeption id:" + this.id);
		}

		System.out.println("Stop: " + this.id);
	}
	
	@Override
	public String toString() {
		return "Thread no " + id;
	}
}
